<template>
  <el-form
    ref="addForm"
    class="dialog-form"
    :model="formData"
    :rules="rules"
    label-width="90px"
  >
    <el-form-item label="勘察任务书" prop="surveySpecificationList">
      <FileUplode
        ref="fileUplode"
        :edit-file-list="surveySpecificationList"
        :status="status"
        :read-only="true"
        @getFileList="getAssignmentBook"
      />
    </el-form-item>
    <el-form-item label="勘察纲要" prop="investigationList">
      <FileUplode
        ref="fileUplode"
        :edit-file-list="investigationList"
        :status="status"
        :read-only="true"
        @getFileList="getOutline"
      />
    </el-form-item>
    <el-form-item label="布孔图" prop="boreholePatternList">
      <FileUplode
        ref="fileUplode"
        :edit-file-list="boreholePatternList"
        :status="status"
        :read-only="true"
        @getFileList="getBoreholePattern"
      />
    </el-form-item>
    <el-form-item label="总平图" prop="soheiMapList">
      <FileUplode
        ref="fileUplode"
        :read-only="true"
        :edit-file-list="soheiMapList"
        :status="status"
        @getFileList="getSoheiMap"
      />
    </el-form-item>
  </el-form>
</template>

<script>
// 上传文件
import FileUplode from '@/components/Upload/FileUplode'
import { getAttachment } from '@/api/projectManage/project'
import { mapState } from 'vuex'
export default {
  name: 'ProFile',
  components: {
    FileUplode
  },
  data() {
    return {
      status: '',
      /* 新增 start*/
      formData: { // 新增数据
        id: '', // 项目id
        surveySpecificationList: [], // 勘察任务书（委托书）
        investigationList: [], // 勘察纲要
        boreholePatternList: [], // 布孔图
        soheiMapList: [] // 总平图
      },
      surveySpecificationList: [], // 回显勘察任务书
      investigationList: [], // 回显勘察纲要
      boreholePatternList: [], // 回显布孔图
      soheiMapList: [], // 回显总平图
      // 表单校验
      rules: {

      }
      /* 新增 end*/
    }
  },
  computed: {
    ...mapState({
      proId: state => state.basicInfo.proId // 项目id
    })
  },
  mounted() {
    this.handleDetail(this.proId)
  },
  methods: {
    async handleDetail(id) {
      const { data } = await getAttachment(id)
      if (data) {
        const { surveySpecification, investigation, boreholePattern, soheiMap } = data
        this.formData = { ...this.formData, surveySpecification, investigation, boreholePattern, soheiMap }
        this.surveySpecificationList = data.surveySpecificationList
        this.investigationList = data.investigationList
        this.boreholePatternList = data.boreholePatternList
        this.soheiMapList = data.soheiMapList
      }
    },
    // 勘察任务书
    getAssignmentBook(fileList, deleteFileIds) {
      this.formData.surveySpecificationList = fileList
    },
    // 勘察纲要
    getOutline(fileList, deleteFileIds) {
      this.formData.investigationList = fileList
    },
    // 勘察报告
    getBoreholePattern(fileList, deleteFileIds) {
      this.formData.boreholePatternList = fileList
    },
    // 总平图
    getSoheiMap(fileList, deleteFileIds) {
      this.formData.soheiMapList = fileList
    }
  }
}
</script>

